﻿Imports System.Data.OleDb
Imports DTO

Public Class LoaiPhongDAO
    Public Function HienThiLoaiPhong() As List(Of LoaiPhongDTO)

        Dim strSQL As String = "select MaLoaiPhong, TenLoaiPhong, DonGia from LOAIPHONG"
        Dim con As OleDbConnection = DataProvider.ConnectionData()
        Dim command As New OleDbCommand(strSQL, con)

        Dim dsLoaiPhong As New List(Of LoaiPhongDTO)
        Dim loaiphong As LoaiPhongDTO
        Dim reader As OleDbDataReader = command.ExecuteReader()

        While (reader.Read())

            loaiphong = New LoaiPhongDTO()
            loaiphong.MaLoaiPhong = reader.GetInt32(0)
            loaiphong.TenLoaiPhong = reader.GetString(1)
            loaiphong.DonGia = reader.GetDouble(2)
            dsLoaiPhong.Add(loaiphong)
        End While

        con.Close()
        Return dsLoaiPhong
    End Function
End Class
